<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>

<!--  -->
<script type="text/javascript" src="../js/jquery/jquery-1.8.0.min.js"></script>
<script type="text/javascript" src="../plug/highcharts/highcharts.js"></script>
<script type='text/javascript' src='../dwr/engine.js'></script>
<script type='text/javascript' src='../dwr/util.js'></script>
<script type='text/javascript' src='../dwr/interface/Pusher.js'></script>
<script>
var $=jQuery.noConflict();
function log(msg){
	console.info(msg)
}
$.extend({
	  getUrlVars: function(){
	    var vars = [], hash;
	    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
	    for(var i = 0; i < hashes.length; i++)
	    {
	      hash = hashes[i].split('=');
	      vars.push(hash[0]);
	      vars[hash[0]] = hash[1];
	    }
	    return vars;
	  },
	  getUrlVar: function(name){
	    return $.getUrlVars()[name];
	  }
	});

function refresh(){
	console.info('refresh')
	initCurve();
}
function initCurve() {
	var seriesData=[];
	function getIntensityCurve(){		
		$.ajax({
			url : '/doroodo/sys/vcxSbTakeStateMonitor_Count_By_State',
			data : null,
			dataType : 'json',
			type: "post", 
			async:true,
			contentType: "application/x-www-form-urlencoded; charset=utf-8", 
			success : function(r) {
				console.info(r);
				getIntensityCurveCallBack(r)
			}
		});
		
	}
	function getIntensityCurveCallBack(data) {
		console.info(data);
		if(data.length<1)
		{
			//loadNullCurve();
			return;	
		}
		seriesData=data;
		$('#container').highcharts(
				{
					 chart: {
				            plotBackgroundColor: null,
				            plotBorderWidth: null,
				            plotShadow: false
				        },
				        title: {
				            text: ''
				        },credits : {
							enabled : false
						},
				        tooltip: {
				    	    pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
				        },
				        plotOptions: {
				            pie: {
				                allowPointSelect: true,
				                cursor: 'pointer',
				                dataLabels: {
				                    enabled: true,
				                    color: '#000000',
				                    connectorColor: '#000000',
				                    format: '<b>{point.name}</b>: 共{point.y} 台'
				                }
				            }
				        },
				        series: [{
				            type: 'pie',
				            name: '断路器保护状态',
				            data: seriesData
				        }]
				});
	}
	getIntensityCurve();
	
}

function eh(msg, ex) {  
    alert(msg + ", date=" + ex.when);  
    //alertMessagesBox('alert-messages-box',"" + dwr.util.toDescriptiveString(exc, 2),true,msg) ;  
}  
  


$(function () {
	console.info('fault.html')
	
	dwr.engine.setErrorHandler(eh);  
	dwr.engine.setActiveReverseAjax(true);
	dwr.engine.setNotifyServerOnPageUnload( true); 
	var vars=$.getUrlVars();
	$('#container').height(vars.height);
	var id=vars.id;
	initCurve(id);
	//setInterval(function(){initCurve(id);},3000);

	
});


</script>
</head>
<body>
<div id="container" style="width:100%;height:100%"><h2>无数据</h2></div>
</body>
</html>